<%@ page import="com.goal98.team.Constants" %>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="layout" content="main"/>
    <title><g:message code="team.search" default="Team Search"/></title>
  </head>
  <body>
    <div class="nav">
    %{--<span class="menuButton"><a class="home" href="${createLinkTo(dir: '')}"><g:message code="home" default="Home" /></a></span>--}%
      <span class="menuButton"><g:link class="list" action="list"><g:message code="team.list" default="Team List"/></g:link></span>
      <g:ifAnyGranted role="${Constants.ROLE_ADMIN}">
        <span class="menuButton">
          <g:link class="create" action="create"><g:message code="team.new" default="New Team"/></g:link>
        </span>
      </g:ifAnyGranted>
    </div>
    <div class="body">
      <h1><g:message code="team.search" default="Team Search"/></h1>
      <g:if test="${flash.message}">
        <div class="message"><g:message code="${flash.message}" args="${flash.args}" default="${flash.defaultMessage}"/></div>
      </g:if>

      <div class="search">
        <g:form action="doSearch">
          <span>
            <input type="text" name="query" value="${query}"/>
          </span>
          <span class="button">
            <input type="submit" value="${message(code: 'button.search', 'default': 'Search')}"/>
          </span>
        </g:form>

      </div>

      <g:if test="${teamInstanceList}">
        <div class="list">
          <table>
            <thead>
              <tr>

                %{--<g:sortableColumn property="id" title="Id" titleKey="team.id" />--}%

                <g:sortableColumn property="name" title="Name" titleKey="team.name"/>

                <g:sortableColumn property="dateCreated" title="Date Created" titleKey="team.dateCreated"/>

                %{--<g:sortableColumn property="lastUpdated" title="Last Updated" titleKey="team.lastUpdated" />--}%

                <g:sortableColumn property="teamAdmins" title="Team Admins" titleKey="team.teamAdmins"/>

              </tr>
            </thead>
            <tbody>
              <g:each in="${teamInstanceList}" status="i" var="teamInstance">
                <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">

                  %{--<td><g:link action="show" id="${teamInstance.id}">${fieldValue(bean: teamInstance, field: "id")}</g:link></td>--}%

                  <td><g:link action="show" id="${teamInstance.id}">${fieldValue(bean: teamInstance, field: "name")}</g:link></td>

                  <td><g:formatDate date="${teamInstance.dateCreated}"/></td>

                  %{--<td><g:formatDate date="${teamInstance.lastUpdated}" /></td>--}%

                  <td>${fieldValue(bean: teamInstance, field: "teamAdmins")}</td>

                </tr>
              </g:each>
            </tbody>
          </table>
        </div>
        <div class="paginateButtons">
          <g:paginate total="${total}"/>
        </div>
      </g:if>
    </div>

  </body>
</html>
